    package cn.varin.mqttclientapi.controller;


    import cn.varin.mqttclientapi.entity.MqttRequestBody;
    import cn.varin.mqttclientapi.handler.UnifiedResponseHandler;
    import cn.varin.mqttclientapi.service.MqttMessageSenderService;
    import cn.varin.mqttclientapi.service.impl.MqttMessageSenderServiceImpl;
    import io.swagger.v3.oas.annotations.Operation;
    import io.swagger.v3.oas.annotations.tags.Tag;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.web.bind.annotation.*;

    @Tag(name = "MQTT服务接口")
    @RestController
    @RequestMapping("/mqtt")
    public class MqttController {

        @Autowired
        private MqttMessageSenderServiceImpl mqttMessageSenderService;

        @Operation(summary = "发送消息，")
        @PostMapping("/send,有qos")
        public UnifiedResponseHandler.Result send(@RequestBody MqttRequestBody mqttRequestBody){
                System.out.println(mqttRequestBody.toString());
            mqttMessageSenderService.send(mqttRequestBody.getMqtt_topic(),mqttRequestBody.getQos(),mqttRequestBody.getPayload());
            return new UnifiedResponseHandler.Result(200,"success",null);
        }
        @Operation(summary = "发送消息,无qos")
        @PostMapping("/send")
        public UnifiedResponseHandler.Result send2(@RequestBody MqttRequestBody mqttRequestBody){
            System.out.println(mqttRequestBody.toString());
            mqttMessageSenderService.send(mqttRequestBody.getMqtt_topic(),mqttRequestBody.getPayload());
            return new UnifiedResponseHandler.Result(200,"success",null);
        }

    }
